package com.wx.proxy.cglib.aop;


import com.wx.proxy.cglib.aop.annotation.Pointcut;
import com.wx.proxy.cglib.aop.annotation.WxAspect;
import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * 日志切面
 * @description:
 * @author: wangxun
 * @createDate: 2021/12/27
 * @version: 1.0
 */
@WxAspect
@Slf4j
public class LogAspect implements MethodInterceptor {

    @Pointcut({"com.wx.proxy.cglib.aop.annotation.Log"})
    public void pointcut(){

    }


    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        log.info("开启日志纪录");
        Object rs = proxy.invokeSuper(obj, args);
        log.info("开闭日志纪录");
        return rs;
    }
}
